package com.imedical.configure;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Swagger配置<br>
 *
 * @author zhongyj
 * @date 2019/7/4
 */
@Slf4j
@Configuration
//@EnableSwagger2
@EnableSwagger2WebMvc
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        log.info("==================== 开启Swagger2配置 ====================");
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("东华医为", "http://www.mediway.com.cn/", "http://www.mediway.com.cn/");
        return new ApiInfoBuilder()
                .title("接口调用文档")
                .description("接口调用")
                .termsOfServiceUrl("http://www.mediway.com.cn")
                .contact(contact)
                .version("1.0.0")
                .build();
    }

}



























